package tech.zhiwei.frostmetal.modules.demo.service.impl;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tech.zhiwei.frostmetal.core.base.service.BaseService;
import tech.zhiwei.frostmetal.modules.demo.dto.DemoDTO;
import tech.zhiwei.frostmetal.modules.demo.entity.Demo;
import tech.zhiwei.frostmetal.modules.demo.mapper.DemoMapper;
import tech.zhiwei.frostmetal.modules.demo.service.IDemoService;
import tech.zhiwei.tool.bean.BeanUtil;

/**
 * 生成代码示例1 Service实现类
 *
 * @author ALIEN 
 * @since 2024/10/10
 */
@Service
@AllArgsConstructor
public class DemoService extends BaseService<DemoMapper, Demo> implements IDemoService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Long saveDemo(DemoDTO demoDTO) {
        Demo Demo = BeanUtil.copyProperties(demoDTO, Demo.class);
        saveOrUpdate(Demo);
        return Demo.getId();
    }
}
